#/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2022/1/17 14:07
# @Author  : wyy
# @Email   : 1915059545@qq.com
# @File    : page_to_grant_authorization.py
# @Software: PyCharm
"""同意隐私授权,并登录页面"""
from selenium.webdriver.common.by import By
from pages.page_base import PageBase
from time import sleep
#点击授权
class PageToGrantAuthorization(PageBase):
    #点击授权登录
    clickauthorize_locator = (By.ID, "com.gfeng.daydaycook:id/checkbox")
    # 点击授权确定
    agree_locator = (By.ID, "com.gfeng.daydaycook:id/btn_agree")
    # qq登录
    qqlogin_locator= (By.XPATH, '//android.widget.ImageView[@resource-id="com.gfeng.daydaycook:id/qqButton"]')
    # 授权登录
    sq_locator = (By.ID, 'com.tencent.mobileqq:id/fds')
    # 返回主页
    jx_locator = (By.ID, 'com.gfeng.daydaycook:id/icon')

    def ele_agree(self):
        #点击已经阅读并同意上述条件
        self.driver.find_element(*self.clickauthorize_locator).click()
        sleep(3)
    def ele_agree_useragreement(self):
        #点击确定同意用户隐私协议概要
        self.driver.find_element(*self.agree_locator).click()
        sleep(3)
    def ele_my(self):
        #点击我的
        self.driver.tap([(512,983)])
        sleep(3)
    def ele_qq(self):
        #点击使用qq登录
        self.driver.find_element(*self.qqlogin_locator).click()
        sleep(3)
    def ele_tograntauthorization(self):
        #点击授权登录
        self.driver.tap([(284,897)])
        sleep(4)
    def ele_homepage(self):
        #点击回到精选主页面
        self.driver.find_element(*self.jx_locator).click()
        sleep(4)

    def click_authorize(self):
        #点击授权功能
        self.ele_agree()
        sleep(3)
        self.ele_agree_useragreement()
        sleep(3)
        self.ele_my()
        sleep(2)
        self.ele_qq()
        sleep(4)
        self.ele_tograntauthorization()
        sleep(8)
        self.ele_homepage()
        sleep(4)